import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../model/category.dart';

class ChildCategory with ChangeNotifier, DiagnosticableTreeMixin {
  List<BxMallSubDto> _childCategoryList = [];
  List<BxMallSubDto> get childCategoryList => _childCategoryList;
  int childIndex = 0;
  String categoryId = '4';
  String subId = ''; // 小类id
  int page = 1; // 列表页数
  String noMoreText = ''; // 显示更多标识

  /// 点击大类更改子类数据
  setChildCategory(List<BxMallSubDto> list, String id) {
    categoryId = id;
    childIndex = 0;
    subId = '';
    page = 1;
    noMoreText = '';
    BxMallSubDto all = BxMallSubDto();
    all.mallSubId = '';
    all.mallCategoryId = '00';
    all.mallSubName = '全部';
    all.comments = 'null';
    _childCategoryList = [all];
    _childCategoryList.addAll(list);
    notifyListeners();
  }

  /// 改变子类索引
  changeChildIndex(int index, String id) {
    childIndex = index;
    subId = id;
    page = 1;
    noMoreText = '';
    notifyListeners();
  }

  increasePage() {
    page++;
  }

  changeNoMore(String text) {
    noMoreText = text;
    notifyListeners();
  }
}
